package com.heima.utils.common;

import com.heima.model.user.pojos.ApUser;

public class AppThreadLocalUtil {
    //定义ThreadLocal对象
    private final static ThreadLocal<ApUser> AP_USER_THREAD_LOCAL = new ThreadLocal<>();

    //添加用户数据到ThreadLocal
    public static void setUser(ApUser apUser){
        AP_USER_THREAD_LOCAL.set(apUser);
    }

    //从ThreadLocal获取用户
    public static ApUser getUser(){
        return AP_USER_THREAD_LOCAL.get();
    }

    //清理用户
    public static void remove(){
        AP_USER_THREAD_LOCAL.remove();
    }
}
